package com.project.common.data.mybatis.mapper;

import com.project.common.data.Model;
import com.project.common.filter.AbstractFilter;
import com.project.common.pagination.PagedRecord;

import java.io.Serializable;
import java.util.List;

public interface ModelMapper<K extends Serializable, M extends Model<K>,
        F extends AbstractFilter<K, F>>
    extends PaginationMapper<K, F> {

    M getModel(K key);

    List<M> listModel(F filter);

    default PagedRecord<M> list(F filter, int pageIndex, int pageSize) {
        return pagination(this::listModel, filter, pageIndex, pageSize);
    }

}
